Skip to content

UpdateActor fails with Aborted while another operation on the actor is in progress - #3131

Merged
Dmitry Berkovich (dberkov) merged 2 commits into
agent-substrate:mainfrom
zoez7:updateactor-lease
Oct 24, 2026
Merged

Dmitry Berkovich (dberkov) merged 2 commits into
agent-substrate:mainfrom
zoez7:updateactor-lease

Conversation

@zoez7

@zoez7 Zoe Zhao (zoez7) commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #3129

UpdateActor now takes the actor lease, like suspend, resume, revert, delete and tag. A caller that races one of them gets Aborted and can retry.

This is to prevent an actor's workerSelector or actorTemplate from getting updated during other operations such as suspend/resume.

AI use: AI-assisted with Claude Code, which drafted the code, test, and this description. I reviewed them.

  • Tests pass
  • Docs updated

Comment thread cmd/ateapi/internal/controlapi/actor.go Outdated
setSpanActorRefAttributes(ctx, actorRef)

storedActor, err := s.impl.UpdateActor(ctx, actorRef, store.PreconditionFrom(inActor), func(toUpdate *ateapi.Actor) error {
leaseCtx, lease, err := acquireLease(ctx, s.impl, actorLeaseKey(actorRef), "actor")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 should-fix 🟡 – ABORTED from UpdateActor now has a second cause, but the API guide still lists only the guard mismatch. Please add the in-progress case to the error line at docs/api-guide.md:663 (worker_selector "in any state" is still true, but not mid-operation). The ReportActorSnapshotState comment in ateapi.proto has the house wording: "Returns ABORTED while another operation is changing the Actor; retry."

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated docs in 78c8ee7.

return nil, err
}

setSpanActorAttributes(ctx, storedActor)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use leaseCtx instead of ctx? It might be worth just reassigning ctx = leaseCtx right after acquiring it to prevent mismatches like this."

@zoez7 Zoe Zhao (zoez7) Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 78c8ee7.

UpdateActor relied only on the uid/version precondition, so it could
interleave with a workflow that holds the actor lease. It now takes the
lease like suspend, resume, revert, delete and tag do.
Reassign ctx to the lease context so later calls cannot use the
parent ctx by mistake. Document that UpdateActor returns ABORTED while
another operation is changing the actor.
@dberkov
Dmitry Berkovich (dberkov) added this pull request to the merge queue Oct 24, 2026
Merged via the queue into agent-substrate:main with commit 0dc6875 Oct 24, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UpdateActor should take the actor lease like the other actor operations

2 participants